package com.ruoyi.od.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.od.domain.OdCommentlike;
import com.ruoyi.od.service.IOdCommentlikeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 评论点赞管理Controller
 * 
 * @author ruoyi
 * @date 2023-08-05
 */
@RestController
@RequestMapping("/od/commentlike")
public class OdCommentlikeController extends BaseController
{
    @Autowired
    private IOdCommentlikeService odCommentlikeService;

    /**
     * 查询评论点赞管理列表
     */
    @PreAuthorize("@ss.hasPermi('od:commentlike:list')")
    @GetMapping("/list")
    public TableDataInfo list(OdCommentlike odCommentlike)
    {
        startPage();
        List<OdCommentlike> list = odCommentlikeService.selectOdCommentlikeList(odCommentlike);
        return getDataTable(list);
    }

    /**
     * 导出评论点赞管理列表
     */
    @PreAuthorize("@ss.hasPermi('od:commentlike:export')")
    @Log(title = "评论点赞管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OdCommentlike odCommentlike)
    {
        List<OdCommentlike> list = odCommentlikeService.selectOdCommentlikeList(odCommentlike);
        ExcelUtil<OdCommentlike> util = new ExcelUtil<OdCommentlike>(OdCommentlike.class);
        util.exportExcel(response, list, "评论点赞管理数据");
    }

    /**
     * 获取评论点赞管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('od:commentlike:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(odCommentlikeService.selectOdCommentlikeById(id));
    }

    /**
     * 新增评论点赞管理
     */
    @PreAuthorize("@ss.hasPermi('od:commentlike:add')")
    @Log(title = "评论点赞管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OdCommentlike odCommentlike)
    {
        return toAjax(odCommentlikeService.insertOdCommentlike(odCommentlike));
    }

    /**
     * 修改评论点赞管理
     */
    @PreAuthorize("@ss.hasPermi('od:commentlike:edit')")
    @Log(title = "评论点赞管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OdCommentlike odCommentlike)
    {
        return toAjax(odCommentlikeService.updateOdCommentlike(odCommentlike));
    }

    /**
     * 删除评论点赞管理
     */
    @PreAuthorize("@ss.hasPermi('od:commentlike:remove')")
    @Log(title = "评论点赞管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(odCommentlikeService.deleteOdCommentlikeByIds(ids));
    }
}
